#include "stdafx.h"

#include <algorithm>

#include "Program.h"

CProgram::CProgram()
{
}

CProgram::~CProgram()
{
}

bool CProgram::AddGlobal(CString Name, CVariable *var)
{
	bool rtn = true;
	if(m_GlobalVars.find(Name) != m_GlobalVars.end())
	{
		rtn = false;
	}
	else
	{
		m_GlobalVars[Name] = var;
	}

	return rtn;
}

bool CProgram::AddFunction(CString Name, CFunction var)
{
	bool rtn = true;

	if(m_Functions.find(Name) != m_Functions.end())
	{
		rtn = false;
	}
	else
	{
		m_Functions[Name] = var;
	}

	return rtn;
}

bool CProgram::HasVariable(CString var, CString fn)
{
	if(m_GlobalVars.find(var) == m_GlobalVars.end() &&
		m_Functions[fn].HasVariable(var) == false)
		return false;

	return true;
}